Crispo - Excel Challenge 46 2024

excel-challenges
weekly-exercises
Easy Sunday Excel Challenge
Published

November 17, 2024

Illustration for Crispo - Excel Challenge 46 2024

Challenge Description

Easy Sunday Excel Challenge

⭐ Problem Date Units Made Defects Running Totals Easy Sunday Excel Challenge

Solutions

library(tidyverse)
library(readxl)

path = "files/Excel Challenge October 17th.xlsx"
input = read_excel(path, range = "B2:D16")
test  = read_excel(path, range = "E2:E16")

result = input %>%
  mutate(group = consecutive_id(Defects)) %>%
  mutate(`Running Totals` = ifelse(Defects != 1, cumsum(`Units Made`), 0), .by = group)
         
all.equal(result$`Running Totals`, test$`Running Totals`)
# [1] TRUE
  • Logic:

    • Reads the workbook range needed for the challenge

    • Builds the intermediate helper columns that drive the final answer

  • Strengths:

    • The R solution stays compact and mirrors the workbook logic closely.
  • Areas for Improvement:

    • The code assumes the workbook layout and named ranges remain stable.
  • Gem:

    • The best part of the solution is choosing a tidy intermediate shape before producing the final answer.
import pandas as pd

path = "files/Excel Challenge October 17th.xlsx"
input = pd.read_excel(path, usecols="B:D", skiprows=1, nrows=15)
test = pd.read_excel(path, usecols="E", skiprows=1, nrows=15)

input['group'] = (input['Defects'] != input['Defects'].shift()).cumsum()
input['Running Totals'] = input.groupby('group')['Units Made'].cumsum().where(input['Defects'] != 1, 0)

print(input['Running Totals'].eq(test['Running Totals']).all()) # True
  • Logic:

    • Reads the workbook range needed for the challenge

    • Aggregates or ranks values at the correct grouping level

  • Strengths:

    • The Python version keeps the same rule in a direct pandas-oriented workflow.
  • Areas for Improvement:

    • As with the R version, any workbook layout change would require small adjustments.
  • Gem:

    • The implementation stays close to the stated challenge instead of adding unnecessary complexity.

Difficulty Level

This task is easy to moderate:

  • The business rule is readable, but the workbook still needs a few careful transformation steps.